package com.system.connect.springboot_flowers.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.system.connect.springboot_flowers.entity.Payments;
import com.system.connect.springboot_flowers.service.IPaymentsService;
import com.system.connect.springboot_flowers.utils.R;
import com.system.connect.springboot_flowers.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 支付表 前端控制器
 * </p>
 *
 * @author yang
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/api/payments")
public class PaymentsController {

    @Autowired
    private IPaymentsService paymentsService;

    /*
    订单获取
     */
    @GetMapping("/getPayments")
    public R getPayments() {

        Integer userId = Integer.valueOf(TokenUtils.getUser());
        QueryWrapper<Payments> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        return R.success(paymentsService.list(queryWrapper));

    }

    /**
     * 订单页获取
     */
    @GetMapping("/getPaymentsPage")
    public R getPaymentsPage(@RequestBody Map<String, Object> payload) {
        //获取前端状态管理内的内容
        String status = (String) payload.get("status");
        System.out.println("==============="+status);
//        Integer userId = Integer.valueOf(TokenUtils.getUser());
//        QueryWrapper<Payments> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("user_id", userId);
//        return R.success(paymentsService.page(null, queryWrapper));
        return R.success("chengg ");

    }

}
